<template>
  <div style="width: 100%">
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column label="登录日期">
        <template slot-scope="scope">
          <span>{{$utils.formatDateTime(scope.row.last_login_time)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="ip" label="IP地址"></el-table-column>
      <el-table-column prop="location" label="归属地"></el-table-column>
      <el-table-column label="信息">
        <template slot-scope="scope">
          <span :style="scope.row.success?'color:#5cb85c':'color:#f7b7b7'">{{scope.row.text}}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isLoaded: false,
      tableData: []
    };
  },
  props: {
    username: {
      type: String,
      default: ""
    }
  },
  created() {
    this.$http
      .post("/log/loginlog", { username: this.username  })
      .then(res => {
        this.isLoaded = true;
        if (res.code == 200) {
          this.tableData = res.data.list;
        } else {
          this.$message.error(res.msg);
        }
      })
      .catch(err => {
        this.$message.error(err.msg);
      });
  }
};
</script>
<style>
</style>

